import {ApiResult} from '@/phr/common/ApiResult';
import {Hospital} from '@/phr/service/hospital/Hospital';
import HttpClient from '@/phr/common/HttpClient';
import {PageDTO} from '@/phr/common/PageDTO';

class HospitalService {


  private SEARCH_HOSPITAL_URL = 'hospital/api/query';
  private GET_HOSPITAL_DETAIL_URL = 'hospital/api/detail';


  /**
   * 根据省市县获取相关医院数据
   * 用作搜索列表，只有ID,NAME两个字段
   * @param {string} provice 省
   * @param {string} city    市
   * @param {string} county  县
   * @param {number} page    页数，默认为1
   * @returns {Promise<ApiResult<Hospital[]>>}
   */
  public async searchHospital(provice: string, city: string, county: string, page: number = 1): Promise<ApiResult<PageDTO<Hospital>>> {
    let params = {
      provice: provice,
      city: city,
      county: county,
      page: page
    };
    return HttpClient.get(this.SEARCH_HOSPITAL_URL, params);
  }


  /**
   * 获取医院的详情信息
   * @param {number} id 医院ID
   * @returns {Promise<ApiResult<Hospital>>}
   */
  public async getHospitalDetail(id: number): Promise<ApiResult<Hospital>> {
    let params = {
      hospitalId: id
    };
    return HttpClient.get(this.GET_HOSPITAL_DETAIL_URL, params);
  }
}

export default new HospitalService()


